<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <input type="text" id="url" />
    <button onclick="fn()">触发</button>
</body>
<script>
    const fn = () => {
        debugger;
        const input = document.getElementById("url");
        let url = input.value;
        const token = localStorage.getItem('access_token');
        fetch(url, {
            "headers": {
                'Authorization': `Bearer ${token}`, // 携带token的方式
                'Content-Type': 'application/json'
            }
        }).then(resp => resp.json())
            .then(json => {
                console.log('response:', json);
            })
    }
</script>

</html>